package com.nowcoder.code.hjnc;

public class NC17 {

    public int getLongestPalindrome(String A, int n) {
        char[] cs = A.toCharArray();
        int result = 1;
        for (int i = 1; i < cs.length; i++) {
            int max = 1;
            int l = i - 1;
            int r = i + 1;
            if (r < cs.length && cs[i] == cs[r]) {
                max++;
                r++;
            }
            if (cs[i] == cs[l]) {
                max++;
                l--;
            }
            while (l >= 0 && r < cs.length && cs[l] == cs[r]) {
                max += 2;
                l--;
                r++;
            }
            result = result > max ? result : max;
        }

        return result;
    }


}
